<template lang="pug">
.pacs-work
  .pacs-work-left
    mt-card.patient-select
      patientQuryForm(@handleQuery="handleQuery")
  .pacs-work-right
    mt-card.patient-list(
      no-padding
    )
      patientWorkList(ref="RefPatientWorkList",@selectRow = "selectRow")
    mt-card.patient-history-list
      mt-tabs(v-model="activeName")
        mt-tab-pane(name="历史检查",label="历史检查", :disabled="historyDisabled")
          historyCheck(ref="RefhistoryCheck")
        mt-tab-pane(name="工作流程",label="工作流程", :disabled="historyDisabled")
          workflow(ref="Refworkflow")
        //- mt-tab-pane(name="住院费用",label="住院费用", :disabled="historyDisabled")
        //-   hospitalizationExpenses
</template>
<script setup lang="ts">
import patientWorkList from "./components/patient-work-list.vue";
import patientQuryForm from "./components/patient-query-form.vue";
import historyCheck from "./components/historyCheck.vue";
import workflow from "./components/workflow.vue";
// import hospitalizationExpenses from "./components/hospitalizationExpenses.vue";
const activeName = ref<null | String>("历史检查");
const selectPatient = ref<Object>({});
const historyDisabled = ref(true);
// 获取子组件的引用
const RefPatientWorkList = ref<InstanceType<typeof patientWorkList>>();
const RefhistoryCheck = ref<InstanceType<typeof historyCheck>>();
const Refworkflow = ref<InstanceType<typeof workflow>>();
// 查询
const handleQuery = (param: any) => {
  if (RefPatientWorkList.value) {
    RefPatientWorkList.value.handleQuery(param);
  }
};
// 选中登记信息
const selectRow = (param: any) => {
  if (RefhistoryCheck.value) {
    RefhistoryCheck.value.handleQuery(param);

  }
  if (Refworkflow.value) {
    Refworkflow.value.handleQuery(param);
  }
  selectPatient.value = param;
  historyDisabled.value = true;
  if (param.id) {
    historyDisabled.value = false;
  }
};
//监听tabs选择改变
watch(
  () => activeName.value,
  (item) => {
    if (item) {
      nextTick(() => {
        selectRow(selectPatient.value);
      });

    }
  },
  {
    immediate: true,
  }
);
</script>

<style lang="less" scoped>
.pacs-work {
  width: 100%;
  height: calc(100% - 0px);
  padding: 0px;
  display: flex;

  &-left {
    height: 100%;
    width: 320px;

    .patient-select {
      width: 100%;
      height: 100%;
      overflow-y: auto;
    }
  }

  &-right {
    height: 100%;
    margin-left: 10px;
    width: calc(100% - 330px);

    .patient-list {
      height: 70%;
      box-sizing: border-box;
    }

    .patient-history-list {
      margin-top: 10px;
      height: calc(30% - 10px);
      box-sizing: border-box;
    }
  }
}
</style>
